<script setup>
import {
  elderlyExport,
  elderlySummary,
} from "@/api/dailyPaper/elderly";
import {useExport, useList} from "@/hooks/useDaily";
import {elderlyColumns} from "../columns";
import {useRouter} from "vue-router";

const router = useRouter();


const {dataSource, CustomTable, getSummary, getList} = useList({
  getFn: elderlySummary
});
const {onExport} = useExport({
  exportFn: elderlyExport,
  fileName: "养老统计数导出"
})

const queryName = (row) =>
    router.push({
      path: `/businessFinance/dailyPaper/agedChild/elderlyDetail/name=${row.name}`,
    });

const handleRefresh = () => getList();
defineExpose({
  handleRefresh,
});
</script>
<template>
  <div class="table_top_btns">
    <el-button @click="onExport">导出</el-button>
  </div>
  <CustomTable
      class="custom_table"
      :index="false"
      :selection="false"
      :indexWidth="100"
      :tableData="dataSource"
      :isPaging="false"
      :tableOption.sync="elderlyColumns"
      showSummary
      :summaryMethod="getSummary"
  >
    <template #name="scope">
      <span
          style="cursor: pointer; color: #fc7037"
          @click="queryName(scope.row)"
      >{{ scope.row.name }}</span
      >
    </template>
  </CustomTable>

</template>
<style lang="scss" scoped>
@import url("@/styles/daily.scss");
</style>
